package com.Smart.smartscals.DataBase;

import java.util.ArrayList;

import com.Smart.smartscals.Entity.ReciveBodyInfoEntity;


import android.content.Context;
import android.database.Cursor;

public class SeletDataBasaUtils {
	Context context;
	DataBaseService mDataService;

	public SeletDataBasaUtils(Context context){
		this.context = context;
	}
	public ArrayList<ReciveBodyInfoEntity> getBodyInfoEntity(long startTime,long endTime,String userName){
		ArrayList<ReciveBodyInfoEntity> bodyInfoEntityArrayList = new ArrayList<ReciveBodyInfoEntity>();
		mDataService = DataBaseService.getInstance(context);
		Cursor cursor = mDataService.seletBodyInfo(startTime, endTime,userName);
		while(cursor.moveToNext()){
			ReciveBodyInfoEntity bodyInfoEntity = new ReciveBodyInfoEntity();
			bodyInfoEntity.setDate(cursor.getLong(cursor.getColumnIndex("date")));
			bodyInfoEntity.setWeight(cursor.getFloat(cursor.getColumnIndex("weight")));
			bodyInfoEntity.setBodyFat(cursor.getFloat(cursor.getColumnIndex("bodyFat")));
			bodyInfoEntity.setWeekNUM(cursor.getInt(cursor.getColumnIndex("weekNUM")));
			bodyInfoEntity.setMonthNUM(cursor.getInt(cursor.getColumnIndex("monthNUM")));
			bodyInfoEntity.setDayNUM(cursor.getInt(cursor.getColumnIndex("dayNUM")));
			bodyInfoEntity.setYearNUM(cursor.getInt(cursor.getColumnIndex("yearNUM")));
			bodyInfoEntity.setUserName(cursor.getString(cursor.getColumnIndex("userName")));
			//加入集合
			bodyInfoEntityArrayList.add(bodyInfoEntity);
			
		}
		if(cursor!=null){
			cursor.close();
		}

		return bodyInfoEntityArrayList;

	}
}
